﻿using Microsoft.SharePoint.WebControls;
using RoketSolutions.SP2010.SecurityTrimming.SecurityTrimming;
using RoketSolutions.SP2010.Infrostructure.Common.Extensions;

namespace RoketSolutions.SP2010.SecurityTrimming.Extenstions
{
    public static class PeopleEditorExtension
    {
         public static AccountEntityType GetAccountType(this PickerEntity pickerEntity)
         {
             if (pickerEntity.EntityData.ContainsKey("PrincipalType"))
             {
                 var principleType = pickerEntity.EntityData["PrincipalType"] as string;
                 if (!principleType.IsNullOrEmpty())
                 {
                     return principleType.EqualByContent("User") ? AccountEntityType.User : AccountEntityType.Group;
                 }
             }
             return AccountEntityType.None;
         }
    }
}